<template>
  <div class="help-panel">
    <h3>帮助中心</h3>
    <section class="faq-section">
      <h4>常见问题</h4>
      <div v-for="(item, idx) in faqs" :key="idx" class="faq-item">
        <div class="faq-q" @click="toggleFaq(idx)">
          <span>{{ item.q }}</span>
          <span class="arrow" :class="{ open: openFaq === idx }">&#9660;</span>
        </div>
        <div v-if="openFaq === idx" class="faq-a">{{ item.a }}</div>
      </div>
    </section>
    <section class="contact-section">
      <h4>联系客服/技术支持</h4>
      <ul>
        <li>邮箱：<a href="mailto:support@example.com">support@example.com</a></li>
        <li>电话：400-123-4567</li>
        <li>QQ：123456789</li>
      </ul>
    </section>
    <section class="feedback-section">
      <h4>在线反馈</h4>
      <form @submit.prevent="submitFeedback">
        <textarea v-model="feedback" placeholder="请输入您的问题或建议..." required></textarea>
        <button type="submit" class="submit-btn">提交反馈</button>
      </form>
      <div v-if="feedbackMsg" class="feedback-msg">{{ feedbackMsg }}</div>
    </section>
  </div>
</template>

<script setup>
import { ref } from 'vue';

const faqs = [
  { q: '如何修改个人信息？', a: '请在“个人中心”页面修改您的个人信息。' },
  { q: '忘记密码怎么办？', a: '请在登录页点击“忘记密码”，根据提示操作。' },
  { q: '如何联系管理员？', a: '您可以通过帮助中心的联系方式联系管理员。' },
  { q: '上传文件有限制吗？', a: '单个文件大小建议不超过10MB，支持常见格式。' },
  { q: '遇到系统异常怎么办？', a: '请及时反馈给技术支持，我们会尽快处理。' },
];
const openFaq = ref(null);
function toggleFaq(idx) {
  openFaq.value = openFaq.value === idx ? null : idx;
}

const feedback = ref('');
const feedbackMsg = ref('');
function submitFeedback() {
  feedbackMsg.value = '感谢您的反馈，我们会尽快处理！';
  feedback.value = '';
  setTimeout(() => { feedbackMsg.value = ''; }, 2000);
}
</script>

<style scoped>
.help-panel {
  max-width: 600px;
  margin: 0 auto;
}
.faq-section, .contact-section, .feedback-section {
  margin-bottom: 28px;
  background: #f8fafc;
  border-radius: 8px;
  padding: 18px 22px 12px 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.faq-section h4, .contact-section h4, .feedback-section h4 {
  margin-bottom: 10px;
  color: #1976d2;
}
.faq-item {
  margin-bottom: 8px;
}
.faq-q {
  cursor: pointer;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #333;
  padding: 6px 0;
}
.faq-q .arrow {
  transition: transform 0.2s;
}
.faq-q .arrow.open {
  transform: rotate(180deg);
}
.faq-a {
  color: #666;
  margin: 4px 0 8px 0;
  padding-left: 8px;
  font-size: 15px;
}
.contact-section ul {
  list-style: none;
  padding: 0;
  color: #444;
}
.contact-section li {
  margin-bottom: 6px;
}
.feedback-section textarea {
  width: 100%;
  min-height: 60px;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px;
  font-size: 15px;
  margin-bottom: 10px;
  resize: vertical;
}
.submit-btn {
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 18px;
  cursor: pointer;
  font-size: 15px;
}
.submit-btn:hover {
  background: #1256a3;
}
.feedback-msg {
  color: #43a047;
  margin-top: 8px;
  font-size: 15px;
}
</style>
